package com.qianxing.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianxing.po.TbCultureDataPO;
import com.qianxing.service.TbCultureDataService;
import com.qianxing.mapper.TbCultureDataMapper;
import com.qianxing.vo.CultureVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author JasonLong
* @description 针对表【tb_culture_data(文创产品表)】的数据库操作Service实现
* @createDate 2023-07-09 22:13:01
*/
@Service
public class TbCultureDataServiceImpl extends ServiceImpl<TbCultureDataMapper, TbCultureDataPO>
    implements TbCultureDataService{

    @Autowired
    TbCultureDataMapper cultureDataMapper;

    @Override
    public List<?> getAll() {

        List<CultureVO> cultureVOS = cultureDataMapper.selectList(null).stream().map(m -> {
            CultureVO cultureVO = new CultureVO();
            cultureVO.setCultureImg(JSON.parseArray(m.getCultureImg()));
            cultureVO.setCultureName(m.getCultureName());
            cultureVO.setCultureId(m.getCultureId());
            cultureVO.setCultureDesc(m.getCultureDesc());
            return cultureVO;
        }).collect(Collectors.toList());

        return cultureVOS;
    }
}




